package pt.uma.gap.ast;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jdt.core.dom.Assignment;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;

public class MethodASTInfo {
	
	private MethodDeclaration methodDeclaration;
	private List<AssignmentInfo> assignmentInfoList = new ArrayList<AssignmentInfo>();
	private List<DeclarationASTInfo> variableInfoList = new ArrayList<DeclarationASTInfo>();
	private List<MethodInvocation> methodInvocationList = new ArrayList<MethodInvocation>();
	private List<ParameterASTInfo> parametersList = new ArrayList<ParameterASTInfo>();
	
	private List<Object> actionList = new ArrayList<Object>();
	
	
	public List<Object> getActionList() {
		return actionList;
	}



	public MethodASTInfo(MethodDeclaration method) {
		this.methodDeclaration = method;
	}
	

	
	public void addAssignment(Assignment node){
		AssignmentInfo assignmentInfo = new AssignmentInfo(node);
		actionList.add(assignmentInfo);
		assignmentInfoList.add(assignmentInfo);
	}
	
	public void addSingleVariableDeclaration(SingleVariableDeclaration node){
		parametersList.add(new ParameterASTInfo(node));
	}
	
	public List<ParameterASTInfo> getParametersList() {
		return parametersList;
	}
	
	
	public void addVariableDeclarationFragment(VariableDeclarationFragment node){
		
		variableInfoList.get(variableInfoList.size()-1).addVariableDeclarationFragment(node);
	}
	
	
	public void addVariableDeclarationStatement(VariableDeclarationStatement node){
		DeclarationASTInfo declarationASTInfo = new DeclarationASTInfo();
		declarationASTInfo.addVariableDeclarationStatement(node);
		actionList.add(declarationASTInfo);
		variableInfoList.add(declarationASTInfo);
		
	}
	
	public void addMethodInvocation(MethodInvocation node){
		actionList.add(node);
		methodInvocationList.add(node);
	}
	

	public MethodDeclaration getMethodDeclaration() {
		return methodDeclaration;
	}



	public List<AssignmentInfo> getAssignmentInfoList() {
		return assignmentInfoList;
	}




	public List<DeclarationASTInfo> getVariableInfoList() {
		return variableInfoList;
	}

	public List<MethodInvocation> getMethodInvocationList(){
		return methodInvocationList;
	}



	public String getMethodName() {
		return getMethodDeclaration().getName().toString();
	}



	public String getReturnType() {
		return getMethodDeclaration().getReturnType2().toString();
	}











	

	

}
